package com.desire.homework;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Random;

/**
 * @author desire
 */
public class _05_随机生成两日期之间的某一天 {
    public static void main(String[] args) throws ParseException {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        //定义开始时间
        String early = "2000-01-01 00:00:00";
        //将开始时间转换为时间戳
        long start = sdf.parse(early).getTime();
        //当前系统时间戳
        long current = System.currentTimeMillis();
        //生成区间内的随机时间戳
        long time = new Random().nextLong(current - start) + start;
        //输出生成的随机时间
        System.out.println(sdf.format(time));


    }
}
